import {SysTagData, SysTagAdd} from "@/pages/tag/type";
import {ReactNode} from "react";
import {UseFetchDataAction} from "@ant-design/pro-table/es/typing";
import {Button, Space} from "antd";
import {ProColumns} from "@ant-design/pro-table";
import {OptionActions} from "@/type/type";
import AddSysTag from "@/pages/tag/list/components/AddSysTag";

// @ts-ignore
const columns: ProColumns<SysTagData> = (optionAction: OptionActions<SysTagAdd, SysTagData>) => {
  return [
    {
      dataIndex: "index",
      valueType: "index",
      title: "序号"

    },
    {
      title: "标签名称",
      dataIndex: "name",
      align: 'center',
    },
    {
      title: "操作",
      valueType: 'option',
      align: "center",
      key: "option",
      width: "200px",
      render: (text: ReactNode, record: SysTagData, index: number, action: UseFetchDataAction<SysTagData>) => {
        return (
          <Space>
            <AddSysTag initialValues={record}
                       {...optionAction.editModal(record, true)}/>
            <Button type="link" danger onClick={() =>
              optionAction.remove([record.id])}>删除</Button>
          </Space>
        )
      }
    }
  ]


}


export default columns;
